Public Class frmAdHoc

    Private _dsAccounts As TargetAccounts
    Private _groupingAttribute As String

    Private Sub frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

    Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click

        RefreshView(txtGroupName.Text)

    End Sub

#Region "Core Functions"

    Private Sub RefreshView(Optional ByVal GroupName As String = "")

        Dim myAD As ADHelper = ADHelper.GetInstance

        Dim properties As String = "cn,sn,givenname,SAMAccountName,mail,initials,lastLogonTimestamp,modifyTimeStamp"
        Dim groupDN As String = "CN=" & GroupName & "," & My.Settings.LDAPOUDN

        Dim dt As DataTable = myAD.getAccounts(myAD.LDAPRoot, "user", groupDN, properties)

        'load the initial data grid with all target accounts
        Dim dv As DataView = New DataView(dt)
        dv.Sort = "cn"

        DataGridView1.DataSource = dv

        Me.ToolStripStatusLabel1.Text = DataGridView1.RowCount & " accounts"

    End Sub

#End Region
End Class